package com.lb.test;

import com.aliyun.tea.TeaConverter;
import com.aliyun.tea.TeaPair;
import lombok.extern.slf4j.Slf4j;

/**
 * 功能描述: 阿里云语音通知<br>
 * @Author: Edward
 * @Date: 2021/5/29 8:41
 */
@Slf4j
public class Client {

    /**
     * 使用AK&SK初始化账号Client
     * @param accessKeyId
     * @param accessKeySecret
     * @param regionId
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.dyvmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret, String regionId) throws Exception {
        com.aliyun.tearpc.models.Config config = new com.aliyun.tearpc.models.Config();
        // 您的AccessKey ID
        config.accessKeyId = accessKeyId;
        // 您的AccessKey Secret
        config.accessKeySecret = accessKeySecret;
        // 您的可用区ID
        config.regionId = regionId;
        return new com.aliyun.dyvmsapi20170525.Client(config);
    }

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        com.aliyun.dyvmsapi20170525.Client client = Client.createClient("LTAIID3oBHZZYqh3",
                "FNt3MXPYt9yZR7LgQ84FE4bRlRapjb", "regionId");
        com.aliyun.dyvmsapi20170525.models.SingleCallByTtsRequest request =
                com.aliyun.dyvmsapi20170525.models.SingleCallByTtsRequest.build(TeaConverter.buildMap(
            // 被叫显号，若您使用的模板为公共号池号码外呼模板，则该字段值必须为空；
            // 若您使用的模板为专属号码外呼模板，则必须传入已购买的号码，仅支持一个号码，您可以在语音服务控制台上查看已购买的号码。
            new TeaPair("calledShowNumber", ""),
            // 被叫号码。仅支持中国内地号码。一次请求仅支持一个被叫号。
            new TeaPair("calledNumber", "15250420158"),
            // 语音文件的语音ID。
            new TeaPair("ttsCode", "TTS_218035622"),
            new TeaPair("ttsParam", "{\"userCall\": \"章先生\",\"planCentent\":\"金鸡湖一号\"}")

        ));
        com.aliyun.dyvmsapi20170525.models.SingleCallByTtsResponse response = client.singleCallByTts(request);
        log.info(response.message);
//        com.aliyun.teaconsole.Client.log(response.message);
    }
}